<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	
	<script type="text/javascript" src="js/jquery-2.1.3.js"></script>
	<script type="text/javascript" src="js/jquery.fn.gantt.js"></script>
		
	<link rel="stylesheet" type="text/css" href="css/gantt.css" />
	<title>demo</title>
</head>
<body>
	<div id="gantt"></div>

	<button id="bu">点击</button>
	<button id="getGanttSourceButton">getGanttSourceButton</button>
	
	
	<script type="text/javascript">
	$(document).ready(function(){	
		var soc = null;
		var getGanttSource = function(){
			

			$.ajax({
				url 	: "PmProductArrange/getGanttSource",
				type 	: "POST",
				async	: false,//取消异步
				data 	: {
				},
				async 	: false,
				success : function(response){
					//alert(response);
					
					var source =  eval('('+response +')');
					var options = {
							
							navigate: "scroll",   //取值为buttons或scroll，作用是使用按钮或滚动条显示数据
							scale: "hours",		//取值为days或weeks，作用是每个月是按周显示还是按日显示
							maxScale: "days",		//months表示最大的显示按月显示
							minScale: "hours",		//days表示最小的显示是按天显示
							itemsPerPage: 7,   //设置每页显示的数目
							onItemClick: function(data) {		//项目点击后所执行的函数
								alert("Item clicked - show some details");
							},
							onAddClick: function(dt, rowId) {
								alert("Empty space clicked - add an item!");
							},
							onRender: function() {
								if (window.console && typeof console.log === "function") {
									console.log("chart rendered");
								}
							}
					};
					options.source = [{
						name: "Sprint 0",		//名称
						desc: "Analysis",		//描述
						values: [{				
							id: "t10",
							from: "/Date(1450555411000)/",
							to: "/Date(1450566208000)/",
							label: "green", 
							customClass: "ganttGreen"
						}]
					}];
					
					$("#gantt").gantt(options);
				},
				error : function() {
					infoAlert("工单查询失败，选择框没有数据");
				}
			});
		}
		$('#getGanttSourceButton').click(function(){
			getGanttSource();
		});
		
		$('#bu').click(function(){
			
			var options = {
					
					navigate: "scroll",   //取值为buttons或scroll，作用是使用按钮或滚动条显示数据
					scale: "hours",		//取值为days或weeks，作用是每个月是按周显示还是按日显示
					maxScale: "days",		//months表示最大的显示按月显示
					minScale: "hours",		//days表示最小的显示是按天显示
					itemsPerPage: 7,   //设置每页显示的数目
					onItemClick: function(data) {		//项目点击后所执行的函数
						alert("Item clicked - show some details");
					},
					onAddClick: function(dt, rowId) {
						alert("Empty space clicked - add an item!");
					},
					onRender: function() {
						if (window.console && typeof console.log === "function") {
							console.log("chart rendered");
						}
					}
			};
/* 			options.source = [{
				name: "Sprint 0",		//名称
				desc: "Analysis",		//描述
				values: [{				//显示的数据
					id: "t01",
					from: "/Date(1320192000000)/",		//开始时间
					to: "/Date(1322401600000)/",		//结束时间
					label: "Requirement Gathering", 	//描述
					customClass: "ganttRed"				//标签颜色
				},{				
					id: "t10",
					from: "/Date(1323802400000)/",
					to: "/Date(1325685200000)/",
					label: "Requirement Gathering", 
					customClass: "ganttGreen"
				}]
			}]; */
			options.source = soc;
			
			$("#gantt").gantt(options);
		});

		getGanttSource();
	});
	</script>
	
	
</body>
</html>